package com.seednia.module.core.xport;

import java.util.List;

import com.seednia.foundation.framework.service.IDataOrientedService;
import com.seednia.foundation.framework.service.ServiceContainer;

/**
 * 
 * @author Young Suk Ahn
 *
 */
public abstract class AbstractXporterBase implements IXporter {
	
	public static final String PNAME_PROCESSOR_SERVICE_ID = "processorServiceId";

	protected String format;
	
	public void setFormat(String format) {
		this.format = format;
	}

	@Override
	public String getFormat() {
		return format;
	}
		
	/**
	 * This method returns a list of class types which is required for 
	 * Jaxb-based XML generation.
	 * This method is mainly used by JAXBContext to load the related classes.
	 * @return list of class types to be imported/exported
	 */
	protected Class<?>[] getXportingTypes()
	{
		List<IDataOrientedService> doServices = ServiceContainer.getInstance().getListByType(IDataOrientedService.class);
		Class<?>[]  retval = new Class<?>[doServices.size()+1];
		
		int i=0;
		retval[i++] = XportDataContainer.class;
		for (IDataOrientedService doService: doServices ) {
			retval[i++] = doService.getRecordClass();
		}
		return retval;
	}

}
